<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        div {
            width: 300px;
            margin: 20px auto;
            text-align: center;

        }

        input {
            margin: 5px 0;
        }

        button {
            cursor: pointer;
        }
    </style>
</head>

<body>

    <div>
        <input type="text" name="yy" value="ha">
        <input type="text" name="yy"  value="chap">
        <input type="button" value="传参" id="yFn" onclick="yFun()">

    </div>

    <script>
        function yFun() {
            var t = document.getElementsByName("yy")
            for(var i = 0; i < t.length; i++) {
               alert(t[i].value)
            }
        }
    </script>
</body>

</html>